/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.crystalcg.filesystem;

import java.io.File;
import java.io.FileWriter;

/**
 *
 * @author lifeng
 */
public class PureFilePower {
    /**
     *
     *
     * @param path 仅支持绝对路径。
     */
    private File file;
    public PureFilePower(String path){
        file=new File(path);
        //System.out.println(file.getParent());
        File parentFile=new File(file.getParent());
        //System.out.println(parentFile.exists());
        if(!parentFile.exists()){
            parentFile.mkdirs();
        }
    }
    public void write(String string){
        try {
            if(!file.exists()){
                 file.createNewFile();
            }
            FileWriter fileWriter=new FileWriter(file,true);
            fileWriter.write(string);
            fileWriter.close();
        } catch (Exception e) {
            System.out.println(e);
        }
    }
}
